/*
Copyright (c) 2008,2009, David Beck

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _rt0d4_rx_conn_cb_h_included_
#define _rt0d4_rx_conn_cb_h_included_

/**
   @file conn_cb.h
   @brief Server side callbacks related to connection handling
*/

#ifndef __cplusplus

#ifndef RT0D4_SECOBJ_CONN_CBS_DEFINED
#define RT0D4_SECOBJ_CONN_CBS_DEFINED

/**
   @brief Callback to destroy the opaque connection related data
   @param conn_data is the pointer to the opaque connection data
   @see rt0d4_rx_SetConnDataDestroyCallBack

   This callback is called when Rx thinks the connection is lost.
   It is required to register the callback w/ rt0d4_rx_SetConnDataDestroyCallBack.
*/
typedef void (*destroy_conn_data)( void * conn_data );

/**
   @brief Callback to create the opaque connection data
   @param login the login as sent by the client
   @param pass the password as sent by the client
   @param cert the certificate data as sent by the client
   @param cert_len the length of the certificate data
   @see rt0d4_rx_SetConnDataCreateCallBack

   This callback is called when the connection is established. It is required
   to register the callback w/ rt0d4_rx_SetConnDataCreateCallBack.
*/
typedef void * (*create_conn_data)( const char * login,
                                    const char * pass,
                                    const unsigned char * cert,
                                    size_t cert_len);

#endif /* RT0D4_SECOBJ_CONN_CBS_DEFINED */

#else /* __cplusplus */

#ifndef RT0D4_SECOBJ_CONN_CBS_DEFINED
#define RT0D4_SECOBJ_CONN_CBS_DEFINED

extern "C" {
  typedef void (*destroy_conn_data)( void * conn_data );
  typedef void * (*create_conn_data)( const char * login,
                                      const char * pass,
                                      const unsigned char * cert,
                                      size_t cert_len );
}

#endif /* RT0D4_SECOBJ_CONN_CBS_DEFINED */

#endif /* __cplusplus */
#endif /* _rt0d4_rx_conn_cb_h_included_ */
